<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        div {
            width: 200px;
            height: 200px;
            background-color: lightblue;
            margin-left: 10px;
            float: left;
        }
        
        .hide {
            display: none;
        }
        
        .show {
            display: block;
        }
    </style>
</head>

<body>
    <input type="button" value="隐藏" onclick="showOrHide(this)">
    <p style="float: none"></p>
    <div>
        one
    </div>

    <div>
        two
    </div>

    <div>
        three
    </div>
    <script>


    function showOrHide(btn) {
        var divs = document.getElementsByTagName("div");

        //遍历所有的div设置className
        for (var i = 0; i < divs.length; i++) {
            //获取每一个div
            var div = divs[i];
            //判断显示隐藏
    		//if (div.className == "" || div.className == "show")
            if (div.className === "hide") {
                div.className = "show";
                btn.value = "隐藏";
            }else{
                div.className = "hide";
                btn.value = "显示";
            }
        }
    }
</script>
</body>

</html>